/*
 * @Author: cooper
 * @Date: 2025-03-30 21:35:19
 * @Wechat: cmd_develop
 * @Description:
 */
#ifndef BSP_EEPROM
#define BSP_EEPROM

#include "common.h"
#include "i2c_application.h"

#define I2C_TIMEOUT 0xFFFFFFF

// #define I2Cx_CLKCTRL                   0xB170FFFF   //10K
// #define I2Cx_CLKCTRL                   0xC0E06969   //50K
#define I2Cx_CLKCTRL 0x80504C4E // 100K
// #define I2Cx_CLKCTRL                   0x30F03C6B   //200K

#define I2Cx_ADDRESS 0xA0

#define I2Cx_PORT I2C2
#define I2Cx_CLK CRM_I2C2_PERIPH_CLOCK
#define I2Cx_DMA DMA1
#define I2Cx_DMA_CLK CRM_DMA1_PERIPH_CLOCK

#define I2Cx_SCL_GPIO_CLK CRM_GPIOB_PERIPH_CLOCK
#define I2Cx_SCL_GPIO_PIN GPIO_PINS_10
#define I2Cx_SCL_GPIO_PinsSource GPIO_PINS_SOURCE10
#define I2Cx_SCL_GPIO_PORT GPIOB
#define I2Cx_SCL_GPIO_MUX GPIO_MUX_4

#define I2Cx_SDA_GPIO_CLK CRM_GPIOB_PERIPH_CLOCK
#define I2Cx_SDA_GPIO_PIN GPIO_PINS_11
#define I2Cx_SDA_GPIO_PinsSource GPIO_PINS_SOURCE11
#define I2Cx_SDA_GPIO_PORT GPIOB
#define I2Cx_SDA_GPIO_MUX GPIO_MUX_4

// AT24C128,一页64个字节
#define EEPROM_PAGE_SIZE 64

void eeprom_init(void);
u8 eeprom_read(u8 page, u8 debug_info);
u8 eeprom_write(u8 page);

void ARM_INIT_POS(void);

#endif
